WARNING: USE "FSPDELTREE" AT YOUR OWN RISK!!! THE AUTHOR ASSUMES NO RESPONSIBILTY FOR THE PERFORMANCE OR RELIABILITY OF THIS SOFTWARE OR ITS ACCOMPANYING DOCUMENTATION!!!
Intro
Among all the wonderful directory and file management routines described by Apple in their "Inside Macintosh - Files" publication, none that I'm aware of is able to delete a non-empty directory. While protecting unknowledgeable, absent-minded, or otherwise careless end users from unintentionally deleting populated directories is clearly desirable, this author feels that (hopefully) competent Macintosh developers should have this common directory management capability. The "FSpDelTree" project has been undertaken to fill this gap.
The Files
The "FSpDelTree 1.10" release is comprised of three files, as follows:
• "FSpDelTree Release Notes" - the text document you are currently reading
• "FSpDelTree.c.o" - an MPW 3.3.x-created C-language object file
• "FSpDelTree.h" - an MPW 3.3.x-created C-language header file
The Function
The public interface to the "FSpDelTree" function, as declared in the "FSpDelTree.h" header file, is:
short FSpDelTree(FSSpecPtr theDeadTree);
The "FSpDelTree" function therefore accepts one argument of type FSSpecPtr. The type FSSpecPtr is defined by Apple as a pointer to an FSSpec structure. The FSSpec structure is also defined by Apple (for specific details regarding these types, please refer to Apple's "Inside Macintosh - Files" publication). Like all the Apple-defined routines described in "Inside Macintosh" that work with FSSpec structures, my "FSpDelTree" function requires Mac System 7.0 or later.
The "FSpDelTree" function returns a short integer value. This value corresponds to the error codes defined by Apple in the "Errors.h" C-language header file.
More Specifics
"FSpDelTree" accepts and will attempt to process any pointer to an FSSpec structure. Therein lies both the power and the danger of using "FSpDelTree".
"FSpDelTree" works like the MS-DOS 6.x "deltree" command: it deletes a directory and all the subdirectories and files within. As with the "deltree" command, "FSpDelTree" also works on files. Since it is possible to create FSSpec structures that represent any directory or file, it is possible to delete any directory or file. "FSpDelTree" does not discriminate on the basis of age, size, color, locked status (files only), or contents. In short, if a file system object (a directory or a file) exists before you call "FSpDelTree", that object will in most cases NOT exist when "FSpDelTree" returns.
"In most cases", you ask? Yes, exceptions to this rule are that "FSpDelTree" cannot delete directories or files that are currently in use, such as a running application (attempting to do so results in an error -47 being returned). Also, "FSpDelTree" makes some attempt to verify that you have passed it a valid pointer to an FSSpec structure. As a precaution against accidentally deleting the default directory, "FSpDelTree" will not process requests to delete the default directory on the default drive (attempting to do so results in an error 128 being returned).
However, "FSpDelTree" cannot read your mind... in the end, it is your resposibility to exercise caution and make sure you are passing the correct information to "FSpDelTree". I STRONGLY URGE anyone who uses "FSpDelTree" to pass it only the address of structures that have been populated by Apple's "FSMakeFSSpec" function.
Common returned values from "FSpDelTree" calls include:
0 no error
-35 volume not found
-43 file not found
-47 file busy (you tried to delete a file that is in use)
128 operation aborted ("FSpDelTree" detected defaults in your FSSpec)
Bugs
I (and others) have more or less fully tested my "FSpDelTree" routine and I believe that we have eliminated all the major bugs. Kindly report any remaining bugs that you may find to one of my electronic mail addresses provided below.
Caveat Emptor
FSpDelTree 1.10 is the first version to be released/unleashed on the public. Previous versions have been incorporated into in-house projects and seem to be working reliably. At this point, I guess it bears repeating that you must USE "FSPDELTREE" AT YOUR OWN RISK!!! THE AUTHOR ASSUMES NO RESPONSIBILTY FOR THE PERFORMANCE OR RELIABILITY OF THIS SOFTWARE OR ITS ACCOMPANYING DOCUMENTATION!!!
The entire "FSpDelTree" project has been written, tested, and produced by the author, James K. Toothman of Essential Technologies. This product is copyrighted by the author and all rights are reserved. This product is intended to be distributed as FREEWARE, meaning you may redistribute it freely as long as you do not eliminate or modify the contents of any of the files. You MAY NOT charge a fee for this product.
Comments, questions, and/or bug reports regarding this product may be directed to the author:
James K. Toothman
Essential Technologies
54 Valley Road
Glen Rock, NJ 07452-1712
AppleLink: JT.ESSENTIAL
AOL: EssentialT
Prodigy: XTWM92F
Anyone wishing to do so may register with me by mail, and I will gladly provide additional FREE upgrades to this product if and when they become available. Please include your name, address, and a crispy, new $1.00 bill (to cover the cost of the diskette and mailing).